{{!
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements.  See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership.  The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License.  You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
}}

<div id="upgrade-history-section">
  <div {{bindAttr class="view.isReady:hide:show :screensaver :no-borders "}}>
    {{view App.SpinnerView}}
  </div>
  <div {{bindAttr class="view.isReady::hidden"}}>
    <div class="row">
      <h2 class="table-title col-sm-3">{{t common.upgrade.history}}</h2>
      <div class="table-controls row col-sm-9 pull-right">
        <div class="col-sm-12">
          <div class="btn-group pull-right">
            <a class="btn btn-default dropdown-toggle" data-toggle="dropdown" href="#">
              <span class="filters-label">{{t common.filter}}: </span>
              <span>
                {{view.selectedCategory.label}}
                <span class="caret"></span>
              </span>
            </a>
            <ul class="dropdown-menu">
              {{#each category in view.categories}}
                <li>
                  <a {{action selectCategory category target="view"}} href="#">
                    {{category.label}}
                  </a>
                </li>
              {{/each}}
            </ul>
          </div>
        </div>
      </div>
    </div>
    <table class="table advanced-header-table table-hover" id="upgrade-summary-table">
      <thead>
      <tr>
        <th>{{t common.direction}}</th>
        <th>{{t common.type}}</th>
        <th class="widest-column">{{t common.repository}}</th>
        <th class="wide-column">{{t common.repositoryType}}</th>
        <th>{{t common.start.time}}</th>
        <th>{{t common.duration}}</th>
        <th>{{t common.end.time}}</th>
        <th>{{t common.status}}</th>
      </tr>
      </thead>
      <tbody class="accordion" id="versionsAccordion">
        {{#if view.pageContent}}
          {{#each item in view.pageContent}}
            <tr>
              <td class="name accordion-group">
                <span class="trim_hostname accordion-heading">
                  <i class="icon-caret-right accordion-toggle"
                     data-toggle="collapse"
                     data-parent="#versionsAccordion"
                     {{bindAttr href="item.idHref"}}></i>
                  <a href="#" class="black"
                     {{action "showUpgradeHistoryRecord" item.stackUpgradeHistoryItem target="view"}}>
                    {{unbound item.directionLabel}}
                  </a>
                </span>
                <div class="accordion-body collapse" {{bindAttr id="item.id"}}>
                  <div class="accordion-inner">
                      {{#each service in item.services}}
                        <div class="row service-version-info">
                          <div class="col-xs-3 service-name">
                            {{service.displayName}}
                          </div>
                          <div class="col-xs-3">
                            <span class="label label-from available">
                              {{service.fromVersion}}
                            </span>
                          </div>
                          <div class="col-xs-3 align-center">
                            <i class="icon-arrow-right"></i>
                          </div>
                          <div class="col-xs-3">
                            <span class="label label-to available">
                              {{service.toVersion}}
                            </span>
                          </div>
                        </div>
                      {{/each}}
                  </div>
                </div>
              </td>
              <td>
                <span>{{item.upgradeTypeLabel}}</span>
              </td>
              <td class="widest-column">
                <span {{bindAttr data-original-title="item.repositoryName"}}>{{item.repositoryName}}</span>
              </td>
              <td class="wide-column">
                <span>{{item.repositoryType}}</span>
              </td>
              <td>
                <span>{{item.startTimeLabel}}</span>
              </td>
              <td>
                <span>{{item.duration}}</span>
              </td>
              <td>
                <span>{{item.endTimeLabel}}</span>
              </td>
              <td>
                <span>{{item.displayStatus}}</span>
              </td>
            </tr>
          {{/each}}
        {{/if}}
      </tbody>
      <tfoot>
        <tr>
          <td colspan="8">
            {{view App.PaginationView}}
          </td>
        </tr>
        </tfoot>
    </table>
  </div>
</div>
